package com.example.controller;

import cn.hutool.core.util.StrUtil;;
import com.example.common.Result;
import com.example.entity.Logs;
import com.example.service.LogsService;
import com.example.service.UserService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 系统日志相关接口
 */
@RestController
@RequestMapping("/logs")
public class LogsController {

    @Autowired
    LogsService logsService;



    /**
     * 删除信息
     */
    @DeleteMapping("/delete/{id}")
    public Result delete(@PathVariable Integer id){
        logsService.removeById(id);
        return Result.success();
    }

    /**
     * 批量删除信息
     */
    @DeleteMapping("/delete/batch")
    public Result deleteBatch(@RequestBody List<Integer> ids){
        logsService.deleteBatch(ids);
        return Result.success();
    }

    @GetMapping("/selectByPage")
    public Result selectPage(Logs logs,
                             @RequestParam(defaultValue = "1") Integer pageNum,
                             @RequestParam(defaultValue = "10") Integer pageSize){
        PageInfo<Logs> page = logsService.selectPage(logs, pageNum, pageSize);
        return Result.success(page);
    }
}